package com.mooc.mymooc.utils.common;

public class MakeCode {
    public static String code(int length){
        String words = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int[] nums = new int[length];
        StringBuilder sb = new StringBuilder();
        for (int i=0;i<length;i++){
            int rand = (int)(Math.random()*words.length());
            nums[i] = rand;
        }
        for (int i=0;i<length;i++){
            char ch = words.charAt(nums[i]);
            sb.append(ch);
        }
        return sb.toString();
    }
}
